<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/view/common/common.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta  charset="UTF-8">
    <title> hiring企业管理后台</title>
    <link rel="stylesheet" href="${ctx }/vendor/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
     <style>
			.topbar {
				position: absolute;·
				right: 100px;
				top: 28px;
			}
			
			.topbar ul li{
				list-style: none;
				float: left;
				padding: 0 5px;
			}	
			
			.tab-content {
				margin-top: 5px;
			}
			
			.form-group {
				margin-bottom: 8px;
			}
		</style>
</head>
<body>
 <h2 class="text-center">企业信息管理后台</h2>
	  <div class="topbar">
	     <ul>
			<li><a href="${ctx }/position_listAll.action">招聘首页</a></li>
	   	  	<li><a href="${ctx }/company_getInfoCompany.action">企业信息</a></li>
	   	  	<li><a href="${ctx }/company_companyLoginout.action">注销</a></li>
	     </ul>
	   </div>
	   <hr>
	   <div class="container">
			<ul class="nav nav-tabs" id="myTabs">
			  <li role="presentation" class="active"><a href="#application"> <span class="glyphicon glyphicon-user"></span> <b>简历审核</b></a></li>
			  <li role="presentation"><a href="#position"> 
			  <span class="glyphicon glyphicon-edit">
			  </span> <b>职位管理</b></a></li>
			</ul>
			<div class="tab-content" id="tabContent">
			    <div class="tab-pane fade in active" id="application">
					<table class="table table-striped table-hover">
				      <thead>
				        <tr>
				          <th>序号</th>
				          <th>职位名称</th>
				          <th>求职者信息</th>
				          <th>申请时间</th>
				          <th>处理时间</th>
				          <th>状态</th>
				          <th>操作</th>
				        </tr>
				      </thead>
				     <tbody>
				      <c:if test="${empty applicationPageModel.list }">
				      		<tr>
								<td colspan="7" align="center">暂无数据！</td>
							</tr>
						</c:if>
						<c:if test="${not empty applicationPageModel.list }">
							<c:forEach items="${applicationPageModel.list }" var="application" varStatus="vs"> 
							    <tr>
								 	<td>${(applicationPageModel.pageNo - 1) * applicationPageModel.pageSize + vs.count }</td>
								 	<td>${application.resumeIntention }</td>
								 	<td>
								 		<a href="javascript:void(0)" title="点击查看求职者信息" data-toggle="modal" onclick="getTalentInfo(${application.talentId}, ${application.resumeId })">${application.talentName }</a>
	                                    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
										  <div class="modal-dialog" role="document">
										    <div class="modal-content">
										      <div class="modal-header">
										        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
										        <h4 class="modal-title" id="myModalLabel">求职者信息</h4>
										      </div>
										      <div class="modal-body">
												<form class="form-horizontal">
													 <div class="form-group">
													    <label for="name" class="col-sm-3 control-label">姓名：</label>
													    <div class="col-sm-6">
													      <input type="text" class="form-control" name="name" id="name" disabled="disabled">
													    </div>
													 </div>
													 <div class="form-group">
													    <label for="age" class="col-sm-3 control-label">年龄：</label>
													    <div class="col-sm-6">
													      <input type="text" class="form-control" name="age" id="age" disabled="disabled">
													    </div>
													  </div>
													  <div class="form-group">
													    <label for="gender" class="col-sm-3 control-label">性别：</label>
													    <div class="col-sm-6">
													      <input type="text" class="form-control" name="gender" id="gender" disabled="disabled">
													    </div>
													  </div>
													  <div class="form-group">
													    <label for="phone" class="col-sm-3 control-label">手机号码：</label>
													    <div class="col-sm-6" style="float: left;">
													      <input type="text" class="form-control" name="phone" id="phone" disabled="disabled">
													    </div>
													  </div>
													  <div class="form-group">
													    <label for="email" class="col-sm-3 control-label">电子邮箱：</label>
													    <div class="col-sm-6">
													      <input type="text" class="form-control" name="email" id="email" disabled="disabled">
													    </div>
													  </div>
													  <div class="form-group">
													    <label for="intention" class="col-sm-3 control-label">求职意向：</label>
													    <div class="col-sm-6">
													      <input type="text" class="form-control" name="intention" id="intention" disabled="disabled">
													    </div>
													  </div>
													  <div class="form-group">
														<label for="workExperience" class="col-sm-2 control-label">职责说明：</label>
														<div class="col-sm-10">
															<textarea rows="5" class="form-control" name="workExperience" id="workExperience" disabled="disabled"></textarea> 
														</div>
													  </div>
													  <div class="form-group">
														<label for="projectExperience" class="col-sm-2 control-label">能力要求：</label>
														<div class="col-sm-10">
															<textarea rows="5" class="form-control" name="projectExperience" id="projectExperience" disabled="disabled"></textarea> 
														</div>
													  </div>
												</form>
										      </div>
										    </div>
										  </div>
										</div>
								 	</td>
								 	<td><fmt:formatDate value="${application.appTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
								 	<td><fmt:formatDate value="${application.handleTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
								 	<td>
								 		<c:if test="${application.status == 1 }">待审核</c:if>
								 		<c:if test="${application.status == 2 }"><span class="text-success">审核通过</span></c:if>
								 		<c:if test="${application.status == 3 }"><span class="text-danger">已拒绝</span></c:if>
								 	</td>
								 	<td><a href="javascript:void(0)" onclick="judge(this, ${application.id}, 2)">通过</a> 
								 	| <a href="javascript:void(0)" onclick="judge(this, ${application.id}, 3)">拒绝</a></td>
							    </tr>
						     </c:forEach>
						     <tr>
						     	<c:if test="${applicationPageModel.totalPages <= 10}">
						     		<c:set var="begin" value="1"></c:set>
						     		<c:set var="end" value="${applicationPageModel.totalPages }"></c:set>
						     	</c:if>
						     	<c:if test="${applicationPageModel.totalPages > 10}">
						     		<c:set var="begin" value="${applicationPageModel.pageNo - 5 }"></c:set>
						     		<c:set var="end" value="${applicationPageModel.pageNo + 4 }"></c:set>
						     		<c:if test="${applicationPageModel.pageNo <= 5}">
										<c:set var="begin" value="1"></c:set>
						     			<c:set var="end" value="10"></c:set>
						     		</c:if>
						     		<c:if test="${end >  applicationPageModel.totalPages}">
										<c:set var="begin" value="${applicationPageModel.totalPages - 10}"></c:set>
						     			<c:set var="end" value="${applicationPageModel.totalPages }"></c:set>
						     		</c:if>
						     	</c:if>
								<td colspan="7" align="center">
									<nav>
									  <ul class="pagination">
									    <li>
									      <a href="${ctx }/CompanyServlet?command=toMainUI&pageNo=${applicationPageModel.pre}">
									        <span>&laquo;</span>
									      </a>
									    </li>
									    <c:forEach begin="${begin }" end="${end }" step="1" var="v">
									    	<li <c:if test="${applicationPageModel.pageNo == v}">class="active"</c:if>><a href="${ctx }/CompanyServlet?command=toMainUI&pageNo=${v }">${v }</a></li>
									    </c:forEach>
									    <li>
									      <a href="${ctx }/CompanyServlet?command=toMainUI&pageNo=${applicationPageModel.next}">
									        <span>&raquo;</span>
									      </a>
									    </li>
									  </ul>
								    </nav>
								</td>
							</tr>
						</c:if>
				      </tbody>
				   </table>
			    </div>
		      <!-- 职位管理操作 -->
		      <div class="tab-pane fade" id="position">
			    	<a href="${ctx }/positionadd.action" class="pull-right">发布职位</a>
			    	<table class="table table-striped table-hover">
				      <thead>
				        <tr>
				          <th>序号</th>
				          <th>职位名称</th>
				          <th>薪资范围</th>
				          <th>发布时间</th>
				          <th>操作</th>
				        </tr>
				      </thead>
				      <tbody>
				      	<c:if test="${empty positionList }">
							<tr>
								<td colspan="5" align="center">暂无数据！</td>
							</tr>
						</c:if>
						<c:if test="${not empty positionList }">
							<c:forEach items="${positionList }" var="position" varStatus="pos">
							    <tr>
								 	<td>${pos.count }</td>
								 	<td><a href="${ctx }/position_positionList.action?positionId=${position.id}">${position.name }</a></td>
								 	<td>${position.salary1 }-${position.salary2 }</td>
								 	<td><fmt:formatDate value="${position.releaseTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
								 	<td><a href="${ctx }/position_getInfoPosition.action?positionId=${position.id}">修改</a> |
								 	    <a href="${ctx }/position_deleteposition.action?positionId=${position.id}">删除</a></td>
							    </tr>
						    </c:forEach>
						</c:if>
				      </tbody>
				   </table>
			    </div>	      
	    </div>
     </div>
	   <script src="${ctx }/vendor/jquery.min.js"></script>
	   <script src="${ctx }/vendor/layer/layer.js"></script>
	   <script src="${ctx }/vendor/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	   	    <!-- 标签切换效果 -->
	   	     <script>
	   	     $('#myTabs a').click(function (e) {
			    e.preventDefault()
			    $(this).tab('show')
		     })
		     
		      /**
		  * 求职者基本信息
		  */
		 function getTalentInfo(talentId, resumeId) {
	   		 var param = {
	   			 talentId: talentId,
	   			 resumeId: resumeId,
	   			 time: new Date().getTime()
	   		 }
			 $.get('${ctx}/talent_getTalentInfoByAjax.action', param, function(data) {
				 $('#name').val(data.name);
				 $('#age').val(data.age);
				 $('#gender').val(data.gender == 1 ? '男' : '女');
				 $('#phone').val(data.phone);
				 $('#email').val(data.email);
				 $('#intention').val(data.interestPositions);
				 $('#workExperience').val(data.workExperience);
				 $('#projectExperience').val(data.projectExperience);
				 $('#myModal').modal();
			 }, 'json')
	   	 }

		 /**
		  * 简历审核
		  */
		 function judge(element, id, result) {
	   		 var param = {
	   		    'applicationId': id,
	   			'applicationStatus': result,
	   			 time: new Date().getTime()
	   		 }
	   		 $.get('${ctx}/application_judgeApplication.action', param, function(data) {
	   			if (data == '') {
	   				layer.msg('审核失败！', {icon: 2})
	   			 } else {
	   				 //父元素的同辈元素的集合
	   				var $status = $(element).parent().prev();
	   				 //同辈元素
	   				var $handleTime = $status.prev();
	   				$status.empty();
	   				$handleTime.empty();
	   				if (result == 2) {
	   					layer.msg('审核通过', {icon: 6})
	   					$status.html('<span class="text-success">审核通过</span>');
	   					$handleTime.html(data);
	   				} 
	   				if (result == 3) {
	   					layer.msg('已拒绝', {icon: 1})
	   					$status.html('<span class="text-danger">已拒绝</span>');
	   					$handleTime.html(data);
	   				}
	   			 }
	   		 })
	   	 }
		 </script>
</body>
</html>